package com.aspose.cells;

class zes {
   static String a(Cells var0, int var1, int var2, zaay var3) {
      Cell var4 = var0.checkCell(var1, var2);
      if (var4 == null) {
         return "";
      } else {
         if (var4.getType() == 5) {
            switch(var4.o().getHorizontalAlignment()) {
            case 1:
            case 2:
               return "^";
            case 3:
            case 5:
            case 6:
            case 7:
               return "'";
            case 4:
               return "\\";
            case 8:
               return "\"";
            }
         }

         return "";
      }
   }

   static double b(Cells var0, int var1, int var2, zaay var3) {
      Style var4 = a(var0, var1, var2);
      if (var4 == null) {
         return 0.0D;
      } else {
         String var5 = var4.s();
         if (var5 != null && !"".equals(var5)) {
            zafy var6 = var3.p.b(var5);
            if (var6.a() == 6) {
               zyb var7 = (zyb)var6;
               zafy[] var8 = var7.d();

               for(int var9 = 0; var9 < var8.length; ++var9) {
                  if (!com.aspose.cells.a.c.zh.a(var8[var9].b().c())) {
                     return 1.0D;
                  }
               }

               zafy var10 = var7.e();
               if (var10 != null) {
                  return com.aspose.cells.a.c.zh.a(var10.b().c()) ? 0.0D : 1.0D;
               } else {
                  return 0.0D;
               }
            } else {
               return com.aspose.cells.a.c.zh.a(var6.b().c()) ? 0.0D : 1.0D;
            }
         } else {
            switch(var4.r()) {
            case 6:
            case 8:
            case 38:
            case 40:
               return 1.0D;
            default:
               return 0.0D;
            }
         }
      }
   }

   static String c(Cells var0, int var1, int var2, zaay var3) {
      Style var4 = a(var0, var1, var2);
      if (var4 == null) {
         return "G";
      } else {
         String var5 = var4.s();
         if (var5 != null && !"".equals(var5)) {
            return a(var5, var3.p.b(var5), var3);
         } else {
            switch(var4.r()) {
            case 0:
               return "G";
            case 1:
               return "F0";
            case 2:
               return "F2";
            case 3:
               return ",0";
            case 4:
               return ",2";
            case 5:
               return "C0";
            case 6:
               return "C0-";
            case 7:
               return "C2";
            case 8:
               return "C2-";
            case 9:
               return "P0";
            case 10:
               return "P2";
            case 11:
               return "S2";
            case 12:
               return "G";
            case 13:
               return "G";
            case 14:
               return "D4";
            case 15:
               return "D1";
            case 16:
               return "D2";
            case 17:
               return "D3";
            case 18:
               return "D7";
            case 19:
               return "D6";
            case 20:
               return "D9";
            case 21:
               return "D8";
            case 22:
               return "D4";
            case 23:
               return ",0";
            case 24:
               return ",0-";
            case 25:
               return ",2";
            case 26:
               return ",2-";
            case 27:
               return "D4";
            case 28:
               return "D4";
            case 29:
               return "D4";
            case 30:
               return "D4";
            case 31:
               return "D4";
            case 32:
               return "D8";
            case 33:
               return "D8";
            case 34:
               return "D4";
            case 35:
               return "D4";
            case 36:
               return "D4";
            case 37:
               return ",0";
            case 38:
               return ",0-";
            case 39:
               return ",2";
            case 40:
               return ",2-";
            case 41:
               return ",0";
            case 42:
               return "C0";
            case 43:
               return ",2";
            case 44:
               return "C2";
            case 45:
               return "G";
            case 46:
               return "G";
            case 47:
               return "G";
            case 48:
               return "S1";
            case 49:
               return "G";
            case 50:
               return "D4";
            case 51:
               return "D4";
            case 52:
               return "D4";
            case 53:
               return "D4";
            case 54:
               return "D4";
            case 55:
               return "D4";
            case 56:
               return "D4";
            case 57:
               return "D4";
            case 58:
               return "D4";
            default:
               return "G";
            }
         }
      }
   }

   static double d(Cells var0, int var1, int var2, zaay var3) {
      Style var4 = a(var0, var1, var2);
      if (var4 == null) {
         return 0.0D;
      } else {
         String var5 = var4.s();
         if (var5 != null && !"".equals(var5)) {
            if (var5.indexOf(40) > -1 && var5.indexOf(41) > -1) {
               zafy var6 = var3.p.b(var5);
               char[] var7 = var6.a(var3.p.k.j(), -111111.0D).g();
               if (var7.length > 1 && var7[0] == '(' && var7[var7.length - 1] == ')') {
                  return 1.0D;
               }

               var7 = var6.a(var3.p.k.j(), 111111.0D).g();
               if (var7.length > 1 && var7[0] == '(' && var7[var7.length - 1] == ')') {
                  return 1.0D;
               }

               var7 = var6.a(var3.p.k.j(), 0.0D).g();
               if (var7.length > 1 && var7[0] == '(' && var7[var7.length - 1] == ')') {
                  return 1.0D;
               }
            }

            return 0.0D;
         } else {
            switch(var4.r()) {
            case 5:
            case 6:
            case 7:
            case 8:
            case 37:
            case 38:
            case 39:
            case 40:
            case 41:
            case 42:
            case 43:
            case 44:
               return 1.0D;
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
            case 17:
            case 18:
            case 19:
            case 20:
            case 21:
            case 22:
            case 23:
            case 24:
            case 25:
            case 26:
            case 27:
            case 28:
            case 29:
            case 30:
            case 31:
            case 32:
            case 33:
            case 34:
            case 35:
            case 36:
            default:
               return 0.0D;
            }
         }
      }
   }

   static double e(Cells var0, int var1, int var2, zaay var3) {
      Style var4 = a(var0, var1, var2);
      if (var4 == null) {
         return 0.0D;
      } else {
         return var4.isLocked() ? 1.0D : 0.0D;
      }
   }

   static String f(Cells var0, int var1, int var2, zaay var3) {
      Cell var4 = var0.checkCell(var1, var2);
      if (var4 == null) {
         return "b";
      } else {
         switch(var4.getType()) {
         case 3:
            return "b";
         case 5:
            return "l";
         default:
            return "v";
         }
      }
   }

   private static Style a(Cells var0, int var1, int var2) {
      int var3 = var0.c(var1, var2);
      return var3 >= 0 && var3 <= var0.r().B().getCount() ? var0.r().B().a(var3) : var0.r().B().a(15);
   }

   private static String a(String var0, zafy var1, zaay var2) {
      String var12;
      switch(var1.a()) {
      case 0:
         zhj var14 = (zhj)var1;
         if (var14.c() != null) {
            return a(var0, var14.c(), var2);
         } else {
            if (var14.d() != null) {
               return a(var0, var14.d(), var2);
            }

            return "G";
         }
      case 1:
      default:
         return "G";
      case 2:
         StringBuilder var13 = new StringBuilder(10);
         zo var15 = (zo)var1;
         a(var0, var15, var2, var13);
         if (var15.d().h()) {
            var13.append("()");
         }

         return com.aspose.cells.b.a.zr.a(var13);
      case 3:
         var12 = a((zl)var1, var2);
         if (a(var0)) {
            return var12 + "()";
         }

         return var12;
      case 4:
         if (a(var0)) {
            return "G()";
         }

         return "G";
      case 5:
         var12 = "S" + ((zhq)var1).d().b();
         if (a(var0)) {
            return var12 + "()";
         }

         return var12;
      case 6:
         zyb var3 = (zyb)var1;
         zxy[] var4 = var3.c();
         zafy[] var5 = var3.d();
         if (var4.length >= 2 && var4[0].b() == 0.0D && var4[1].b() == 0.0D && (var4[0].a() == 2 || var4[0].a() == 3) && var4[1].a() == 4) {
            StringBuilder var16 = new StringBuilder(10);
            zafy var7 = var5[0];
            zafy var8 = var5[1];
            if (var7.a() == 2) {
               a(var7.b().a(), (zo)var7, var2, var16);
            } else if (var8.a() == 2) {
               a(var7.b().a(), (zo)var8, var2, var16);
            } else {
               if (var7.a() == 1 && var8.a() == 1 && ((zht)var7).e() && ((zht)var8).e() && ((zht)var7).d() < 1 && ((zht)var8).d() < 1) {
                  if (var5.length < 3) {
                     return "H";
                  }

                  boolean var9 = true;

                  for(int var10 = 2; var10 < var5.length; ++var10) {
                     zafy var11 = var5[var10];
                     if (var11.a() != 1 || !((zht)var11).e() || ((zht)var11).d() > 0) {
                        var9 = false;
                        break;
                     }
                  }

                  if (var9) {
                     return "H";
                  }
               }

               var16.append(a(var7.b().a(), var7, var2));
            }

            if (!com.aspose.cells.a.c.zh.a(var7.b().c()) || !com.aspose.cells.a.c.zh.a(var8.b().c())) {
               var16.append('-');
            }

            if (var7.a() == 2) {
               if (((zo)var7).d().h()) {
                  var16.append("()");
               }
            } else if (a(var7.b().a())) {
               var16.append("()");
            }

            return com.aspose.cells.b.a.zr.a(var16);
         } else {
            zafy var6 = var5[0];
            return a(var6.b().a(), var6, var2);
         }
      }
   }

   private static boolean a(String var0) {
      if (var0 != null) {
         char[] var1 = var0.toCharArray();
         int var2 = 0;

         while(var2 < var1.length) {
            if (var1[var2] == '(') {
               return true;
            }

            if (var1[var2] == '\\') {
               ++var2;
               if (var2 >= var1.length) {
                  break;
               }

               if (var1[var2] == '(') {
                  return true;
               }

               ++var2;
            } else {
               var2 = zj.b(var1, var2, var1.length);
            }
         }
      }

      return false;
   }

   private static String a(zl var0, zaay var1) {
      if (!var0.b(1) && !var0.b(128)) {
         if (var0.b(2) && var0.b(4)) {
            return var0.c() ? "D2" : "D5";
         } else if (var0.b(64)) {
            return var0.b(32) ? "D6" : "D7";
         } else if (var0.b(8) && var0.b(16)) {
            return var0.b(32) ? "D8" : "D9";
         } else {
            return "G";
         }
      } else if (var0.b(4)) {
         switch(var0.d()) {
         case 2:
            if (var0.b(256)) {
               return "D2";
            }

            return "D4";
         case 3:
            return "D1";
         case 4:
            if (var1.p.k.f().f() == 4) {
               return "D1";
            }

            return "G";
         default:
            return "G";
         }
      } else {
         return var0.b(256) ? "D1" : "D3";
      }
   }

   private static void a(String var0, zo var1, zaay var2, StringBuilder var3) {
      int var4 = var0.indexOf(var2.p.k.a().d().d());
      if (var4 > -1) {
         char var5 = var2.p.k.a().d().d().charAt(0);
         char[] var6 = var0.toCharArray();

         label61:
         for(int var7 = 0; var7 < var6.length; ++var7) {
            switch(var6[var7]) {
            case '"':
            case '\'':
               if (var7 < var6.length - 2 && var6[var7 + 2] == var6[var7] && var6[var7 + 1] == var5) {
                  var3.append('C');
                  var3.append(var1.d().b());
                  return;
               }

               char var8 = var6[var7];
               ++var7;

               while(true) {
                  if (var7 >= var6.length) {
                     continue label61;
                  }

                  if (var6[var7] == var8) {
                     ++var7;
                     continue label61;
                  }

                  ++var7;
               }
            case '[':
               ++var7;

               while(true) {
                  if (var7 >= var6.length) {
                     continue label61;
                  }

                  if (var6[var7] == ']') {
                     ++var7;
                     continue label61;
                  }

                  ++var7;
               }
            default:
               if (var6[var7] == var5) {
                  var3.append('C');
                  var3.append(var1.d().b());
                  return;
               }
            }
         }
      }

      if (var1.d().a() != 1.0D && (int)com.aspose.cells.b.a.zq.a(Math.log10(var1.d().a())) % 3 != 0) {
         var3.append('P');
      } else if (var1.d().g()) {
         var3.append(',');
      } else {
         var3.append('F');
      }

      var3.append(var1.d().b());
   }
}
